<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<script src="js/vue.js"></script>

<div id="app">
    姓:<input v-model="firstName" placeholder="输入姓氏"/>
    名:<input v-model="lastName" placeholder="输入名">
    姓名: <input v-model="fullName"/>
    <p>{{fullName}}</p>
</div>
<script>
    var vm = new Vue({
        el: "#app",
        data: {
            firstName: "A",
            lastName: "B",
        },
        computed: {
            fullName: {
                get: function () {
                    return this.firstName + " " + this.lastName;
                },
                set: function (newValue) {
                    var name = newValue.split(" ");
                    this.firstName = name[0];
                    this.lastName = name[1];
                }
            }
        },

    });
	console.log(vm.fullName);
</script>

</body>
</html>
